package com.boliq.lol.ui.fragment;


import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.boliq.lol.R;
import com.boliq.lol.adapter.NewsAdapter;
import com.boliq.lol.base.BaseFragment;
import com.boliq.lol.bean.NewsBean;

import java.util.ArrayList;
import java.util.List;

public class GameFragment extends BaseFragment implements View.OnClickListener {
    private RecyclerView listView;
    private NewsAdapter mNewsAdapter;
    ImageView iv1;
    ImageView iv2;
    ImageView iv3;
    ImageView iv4;
    ImageView iv5;
    TextView iv6;
    TextView iv7;

    @Override
    protected int rootLayout() {
        return R.layout.fragment_game;
    }

    @Override
    protected void initView(View view) {
        iv1=view.findViewById(R.id.im1);
        iv2=view.findViewById(R.id.im2);
        iv3=view.findViewById(R.id.im3);
        iv4=view.findViewById(R.id.im4);
        iv5=view.findViewById(R.id.im5);
        iv1.setOnClickListener(this);
        iv2.setOnClickListener(this);
        iv3.setOnClickListener(this);
        iv4.setOnClickListener(this);
        iv5.setOnClickListener(this);
        listView = view.findViewById(R.id.rv_news_content);
        listView.setLayoutManager(new LinearLayoutManager(getActivity()));

        iv6=view.findViewById(R.id.saicheng);
        iv6.setOnClickListener(this);
        iv7=view.findViewById(R.id.zhibo);
        iv7.setOnClickListener(this);

        mNewsAdapter = new NewsAdapter();

        mNewsAdapter.setList(init());
        listView.setAdapter(mNewsAdapter);

    }
    //这里适用于模拟数据创建的假数据
    private String[] title = new String[]{"LPL赛事没品图：7的意志无处不在，马老师要女装了？",
            "EDG 2:0 LNG 人马开团势不可挡EDG晋级季后赛",
            "WE 2:1 OMG Beishang人马冲阵摧毁后排",
            "【坐谈客耳】 ：LNG的春季赛之旅能走多远？",
            "LOL中韩7支率先晋级季后赛战队一览！猪狗归来",
            "不骄不躁EDG！横扫LNG后Jiejie表示：队伍仍在上升期",
            "EDG成功晋级季后赛！前期进攻依然猛烈 圣枪哥状态略有起伏",
            "EDG零封LNG，圣枪哥一战洗白，泰山的表情尽显无奈",
            "EDG零封LNG晋级季后赛！队员赛后笑开了花！杰杰采访粉丝泪目",
            "全华班的崛起？春季赛常规赛战队积分榜前四有三支是全华班的",
            "WE击败OMG 人马成为版本之子 Karsa早就已发现获胜密码",
            "WE击败OMG取得四连胜！马老师却恨铁不成钢：打得太臭了！",
            "LPL春季赛名场面：SN高地完美开团，焕风卡莎收割...",
            "小蜜蜂宝典-永久皮肤宝箱重开功能上线公告",
            "KSG引入诺夏后终止连败 时隔943天电棍再度获得BO3胜利"

    };
    private int[] cover = new int[]{
            R.drawable.vateral_1,
            R.drawable.vateral_2,
            R.drawable.vateral_3,
            R.drawable.vateral_4,
            R.drawable.vateral_5,
            R.drawable.vateral_6,
            R.drawable.vateral_7,
            R.drawable.vateral_8
    };

    private List<NewsBean> init() {
        List<NewsBean> list = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            list.add(new NewsBean()
                    .setTitle(title[i % title.length])
                    .setHot((int) (Math.random() * 1000))
                    .setDrawable(cover[i % cover.length]));
        }
        return list;
    }
    @Override
    protected void initData() {

    }

    @Override
    protected void bindEvent() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.im1:
                Toast.makeText(getActivity(),"全部赛程",Toast.LENGTH_SHORT).show();
                break;
            case R.id.im2:
                Toast.makeText(getActivity(),"赛程数据",Toast.LENGTH_SHORT).show();

                break;
            case R.id.im3:
                Toast.makeText(getActivity(),"赛事视频",Toast.LENGTH_SHORT).show();

                break;
            case R.id.im4:
                Toast.makeText(getActivity(),"俱乐部",Toast.LENGTH_SHORT).show();

                break;
            case R.id.im5:
                Toast.makeText(getActivity(),"赛事购票",Toast.LENGTH_SHORT).show();

                break;
            case R.id.saicheng:
                Toast.makeText(getActivity(),"最新赛程",Toast.LENGTH_SHORT).show();

                break;
            case R.id.zhibo:
                Toast.makeText(getActivity(),"全部直播",Toast.LENGTH_SHORT).show();

                break;
        }
    }
}
